# Manhatan  drought
library(ggrepel)
## Loading required package: ggplot2
library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.5-3
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
rm(list = ls())
load("EPICON.data.preparation.RC.bNTI.ghost.2019.03.17.Rdata")


otu_table0<-data.frame(t(fung.raw)) ##Read in the raw data###
row.names(otu_table0)<-row.names(ID)
otu_table1<-data.frame(t(otu_table0[ID$Kingdom=="Fungi",]))
env$Treatment1<-factor(env$Treatment1,levels=c("Control", "Pre_flowering_drought", "Post_flowering_drought"))

manhatan.drought<- function (habitat,tp, Ntreat, treat)
{
  fung<-otu_table1[env$Habitat == habitat, ]
  fung<-fung[,colSums(fung)>0]
  subse<- env$Habitat == habitat & env$TP> tp & env$Treatment1 != Ntreat
  fung.subs<-otu_table1[subse,]
  set.seed(315)
  
  fung.subs<-data.frame(rrarefy(fung.subs, min(rowSums(fung.subs))))
  com<-fung.subs[,colSums(fung.subs)>0]
  env.subs<-env[subse,]
  va<-env.subs[, treat]
  paov<-adonis(com~va)
  print(paov)
  dvoc<-data.frame()
  for (i in c(1: ncol(com)))
  {
    tt<-t.test(com[,i]~va)  # t test
    p<-tt$p.value           # pvalue of t test
    name<-colnames(com)[i]  # OTU name
    fs<-aggregate(com[,i], by=list(va), FUN=mean) # mean abundance of OTU in two habitats
    fc<-log2((fs[1,2]+1)/(fs[2,2]+1))  
    abu<-log2(colSums(com)[i]/nrow(com)+1)
    dd<-data.frame(fc,p,   name,abu, i, " ")
    dvoc<-rbind(dvoc, dd)
  }
  dvoc<-data.frame(dvoc)
  names(dvoc)<-c("log2FoldChange", "pvalue","name", "log2AverageAbundance", "order", "Group")
  dvoc$padj<-p.adjust(dvoc$pvalue, n = length(dvoc$pvalue))
  dvoc$neglogp = -log(dvoc$pvalue)
  
  dvoc$level = as.factor(ifelse( dvoc$log2FoldChange > 0, "Control > Drought", "Drought > Control"))
  dvoc$level<-factor(dvoc$level,levels=c("Control > Drought","Drought > Control"))
  
  x<-droplevels(merge(dvoc,ID,  by.y = "OTU.ID.1", by.x = "name", all = FALSE))
  x = arrange(x, Guild,Genus,log2AverageAbundance,neglogp)
  x<-x[order(x$Guild),]
  x$name = factor(x$name, levels=x$name) 
  x1<-droplevels(x[x$neglogp >=10,])
  pos<-droplevels(x1[x1$log2FoldChange>0,])
  neg<-droplevels(x1[x1$log2FoldChange<0,])
  print(pos$name)
  print(neg$name)
  p1<-ggplot(x, aes(x=name, y=neglogp, color=Guild, size=log2AverageAbundance, shape=level)) +
    geom_point(alpha = 0.6) + 
    geom_text_repel(data=subset(x, neglogp > 10),vjust="inward",hjust="inward", 
                    aes(label=Genus), angle = 0, size=3, color="black",fontface= "bold")+
    geom_hline(yintercept= 10, linetype=1, color="green") +
    scale_shape_manual(values=c(1, 2))+
    scale_size(breaks=c(5, 10, 15)) +
    labs(x=" ", y=" ") + 
    scale_color_manual(values=c("green","blue","purple","black","chocolate", "red","grey"))+
    theme(axis.ticks.x=element_blank(),axis.text.x=element_blank())+
    theme(panel.background = element_rect(fill = NA),legend.position = "none") + 
    labs(title = habitat, x = "", y=" ", size = "log(Average Abundance)", shape = "Sorghum effect") +
    theme(axis.line = element_line(linetype = "solid"))  +
    theme(axis.text.y = element_text(size = 12)) +
    theme(axis.text.y = element_text(colour = "black"))
  return(p1)
}

manhatan.drought("Leaf", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)  
## va          1    0.3069 0.30687  2.0272 0.01126  0.091 .
## Residuals 178   26.9445 0.15137         0.98874         
## Total     179   27.2514                 1.00000         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## factor(0)
## Levels: 
## factor(0)
## Levels:

manhatan.drought("Leaf", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs  MeanSqs F.Model      R2 Pr(>F)    
## va         1   0.28097 0.280967  13.219 0.12329  0.001 ***
## Residuals 94   1.99791 0.021254         0.87671           
## Total     95   2.27888                  1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] OTU124_Cryptococcus      OTU24_Cryptococcus      
## [3] OTU282_Cystofilobasidium OTU145_Cryptococcus     
## [5] OTU69_Tremellomycetes    OTU61_Cryptococcus      
## [7] OTU14_Symmetrospora     
## 7 Levels: OTU124_Cryptococcus ... OTU14_Symmetrospora
## [1] OTU27_Alternaria  OTU53_Stemphylium OTU1_Cladosporium
## Levels: OTU27_Alternaria OTU53_Stemphylium OTU1_Cladosporium

manhatan.drought("Root", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va          1    5.8756  5.8756  50.306 0.22034  0.001 ***
## Residuals 178   20.7901  0.1168         0.77966           
## Total     179   26.6658                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU126_Glomus          OTU213_Rhizophagus     OTU118_Rhizophagus    
##  [4] OTU106_Sordariomycetes OTU322_Fusarium        OTU32_Fusarium        
##  [7] OTU16_Fusarium         OTU18_Gibberella       OTU19_Sarocladium     
## [10] OTU2_Setophoma         OTU136_Auriculariales  OTU110_Myrmecridium   
## [13] OTU35_Myrothecium      OTU197_Fungi           OTU535_Pezizaceae     
## [16] OTU151_Vermispora     
## 16 Levels: OTU126_Glomus OTU213_Rhizophagus ... OTU151_Vermispora
## [1] OTU5_Acremonium        OTU22_Periconia        OTU105_Aspergillus    
## [4] OTU109_Beauveria       OTU97_Penicillium      OTU221_Spiromastix    
## [7] OTU102_Arthropsis      OTU212_Sordariomycetes
## 8 Levels: OTU5_Acremonium OTU22_Periconia ... OTU212_Sordariomycetes

manhatan.drought("Root", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va         1    1.1178 1.11777  19.503 0.17183  0.001 ***
## Residuals 94    5.3874 0.05731         0.82817           
## Total     95    6.5052                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU229_Glomus          OTU126_Glomus          OTU133_Glomus         
##  [4] OTU213_Rhizophagus     OTU132_Rhizophagus     OTU161_Rhizophagus    
##  [7] OTU118_Rhizophagus     OTU150_Rhizophagus     OTU166_Rhizophagus    
## [10] OTU106_Sordariomycetes OTU182_Ascomycota      OTU123_Hypocreales    
## [13] OTU60_Hypocreales      OTU153_Auriculariales  OTU136_Auriculariales 
## [16] OTU1_Cladosporium      OTU319_Entoloma        OTU110_Myrmecridium   
## [19] OTU56_Agaricomycetes   OTU55_Panaeolus        OTU23_Stachybotrys    
## [22] OTU535_Pezizaceae     
## 22 Levels: OTU229_Glomus OTU126_Glomus ... OTU535_Pezizaceae
## [1] OTU16_Fusarium OTU486_Fungi  
## Levels: OTU16_Fusarium OTU486_Fungi

manhatan.drought("Rhizosphere", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va          1     3.594  3.5941  22.264 0.11117  0.001 ***
## Residuals 178    28.734  0.1614         0.88883           
## Total     179    32.329                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU408_Fungi           OTU106_Sordariomycetes OTU322_Fusarium       
##  [4] OTU41_Fusarium         OTU32_Fusarium         OTU16_Fusarium        
##  [7] OTU6_Fusarium          OTU18_Gibberella       OTU19_Sarocladium     
## [10] OTU136_Auriculariales  OTU83_Cladosporium     OTU35_Myrothecium     
## [13] OTU151_Vermispora     
## 13 Levels: OTU408_Fungi OTU106_Sordariomycetes ... OTU151_Vermispora
## [1] OTU5_Acremonium    OTU222_Aspergillus OTU105_Aspergillus
## [4] OTU109_Beauveria   OTU97_Penicillium  OTU221_Spiromastix
## 6 Levels: OTU5_Acremonium OTU222_Aspergillus ... OTU221_Spiromastix

manhatan.drought("Rhizosphere", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va         1    2.9474 2.94741  31.177 0.24906  0.001 ***
## Residuals 94    8.8866 0.09454         0.75094           
## Total     95   11.8340                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU106_Sordariomycetes OTU27_Alternaria       OTU4_Alternaria       
##  [4] OTU11_Epicoccum        OTU136_Auriculariales  OTU83_Cladosporium    
##  [7] OTU1_Cladosporium      OTU319_Entoloma        OTU24_Cryptococcus    
## [10] OTU10_Filobasidium     OTU69_Tremellomycetes  OTU90_Rhodotorula     
## [13] OTU26_Sporobolomyces   OTU14_Symmetrospora   
## 14 Levels: OTU106_Sordariomycetes OTU27_Alternaria ... OTU14_Symmetrospora
## [1] OTU5_Acremonium   OTU32_Fusarium    OTU16_Fusarium    OTU18_Gibberella 
## [5] OTU19_Sarocladium OTU2_Setophoma    OTU137_Eurotiales OTU97_Penicillium
## [9] OTU197_Fungi     
## 9 Levels: OTU5_Acremonium OTU32_Fusarium ... OTU197_Fungi

manhatan.drought("Soil", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va          1     0.715 0.71500  6.2473 0.03391  0.001 ***
## Residuals 178    20.372 0.11445         0.96609           
## Total     179    21.087                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] OTU133_Glomus OTU277_Glomus OTU224_Glomus OTU206_Glomus
## Levels: OTU133_Glomus OTU277_Glomus OTU224_Glomus OTU206_Glomus
## [1] OTU51_Rhizophagus     OTU5_Acremonium       OTU170_Fungi         
## [4] OTU17_Acrophialophora OTU59_Chaetomium     
## 5 Levels: OTU51_Rhizophagus OTU5_Acremonium ... OTU59_Chaetomium

manhatan.drought("Soil", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va         1    0.4663 0.46633  4.4716 0.04541  0.001 ***
## Residuals 94    9.8031 0.10429         0.95459           
## Total     95   10.2694                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] OTU14_Symmetrospora
## Levels: OTU14_Symmetrospora
## [1] OTU17_Acrophialophora OTU97_Penicillium    
## Levels: OTU17_Acrophialophora OTU97_Penicillium

manhatan.drought<- function (habitat,tp, Ntreat, treat)
{
  fung<-otu_table1[env$Habitat == habitat, ]
  fung<-fung[,colSums(fung)>0]
  subse<- env$Habitat == habitat & env$TP> tp & env$Treatment1 != Ntreat
  fung.subs<-otu_table1[subse,]
  set.seed(315)
  
  fung.subs<-data.frame(rrarefy(fung.subs, min(rowSums(fung.subs))))
  com<-fung.subs[,colSums(fung.subs)>0]
  env.subs<-env[subse,]
  va<-env.subs[, treat]
  paov<-adonis(com~va)
  print(paov)
  dvoc<-data.frame()
  for (i in c(1: ncol(com)))
  {
    tt<-t.test(com[,i]~va)  # t test
    p<-tt$p.value           # pvalue of t test
    name<-colnames(com)[i]  # OTU name
    fs<-aggregate(com[,i], by=list(va), FUN=mean) # mean abundance of OTU in two habitats
    fc<-log2((fs[1,2]+1)/(fs[2,2]+1))  
    abu<-log2(colSums(com)[i]/nrow(com)+1)
    dd<-data.frame(fc,p,   name,abu, i, " ")
    dvoc<-rbind(dvoc, dd)
  }
  dvoc<-data.frame(dvoc)
  names(dvoc)<-c("log2FoldChange", "pvalue","name", "log2AverageAbundance", "order", "Group")
  dvoc$padj<-p.adjust(dvoc$pvalue, n = length(dvoc$pvalue))
  dvoc$neglogp = -log(dvoc$pvalue)
  
  dvoc$level = as.factor(ifelse( dvoc$log2FoldChange > 0, "Control > Drought", "Drought > Control"))
  dvoc$level<-factor(dvoc$level,levels=c("Control > Drought","Drought > Control"))
  
  x<-droplevels(merge(dvoc,ID,  by.y = "OTU.ID.1", by.x = "name", all = FALSE))
  x = arrange(x, Guild,Genus,log2AverageAbundance,neglogp)
  x<-x[order(x$Guild),]
  x$name = factor(x$name, levels=x$name) 
  x1<-droplevels(x[x$neglogp >=10,])
  pos<-droplevels(x1[x1$log2FoldChange>0,])
  neg<-droplevels(x1[x1$log2FoldChange<0,])
  print(pos$name)
  print(neg$name)
  p1<-ggplot(x, aes(x=name, y=neglogp, color=Guild, size=log2AverageAbundance, shape=level)) +
    geom_point(alpha = 0.6) + 
    #geom_text_repel(data=subset(x, neglogp > 10),vjust="inward",hjust="inward", 
    #                aes(label=Genus), angle = 0, size=3, color="black",fontface= "bold")+
    geom_hline(yintercept= 10, linetype=1, color="green") +
    scale_shape_manual(values=c(1, 2))+
    scale_size(breaks=c(5, 10, 15)) +
    labs(x=" ", y=" ") + 
    scale_color_manual(values=c("green","blue","purple","black","chocolate", "red","grey"))+
    theme(axis.ticks.x=element_blank(),axis.text.x=element_blank())+
    theme(panel.background = element_rect(fill = NA),legend.position = "none") + 
    labs(title = habitat, x = "", y=" ", size = "log(Average Abundance)", shape = "Sorghum effect") +
    theme(axis.line = element_line(linetype = "solid"))  +
    theme(axis.text.y = element_text(size = 12)) +
    theme(axis.text.y = element_text(colour = "black"))
  return(p1)
}

manhatan.drought("Leaf", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)  
## va          1    0.3069 0.30687  2.0272 0.01126  0.091 .
## Residuals 178   26.9445 0.15137         0.98874         
## Total     179   27.2514                 1.00000         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## factor(0)
## Levels: 
## factor(0)
## Levels:

manhatan.drought("Leaf", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs  MeanSqs F.Model      R2 Pr(>F)    
## va         1   0.28097 0.280967  13.219 0.12329  0.001 ***
## Residuals 94   1.99791 0.021254         0.87671           
## Total     95   2.27888                  1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] OTU124_Cryptococcus      OTU24_Cryptococcus      
## [3] OTU282_Cystofilobasidium OTU145_Cryptococcus     
## [5] OTU69_Tremellomycetes    OTU61_Cryptococcus      
## [7] OTU14_Symmetrospora     
## 7 Levels: OTU124_Cryptococcus ... OTU14_Symmetrospora
## [1] OTU27_Alternaria  OTU53_Stemphylium OTU1_Cladosporium
## Levels: OTU27_Alternaria OTU53_Stemphylium OTU1_Cladosporium

manhatan.drought("Root", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va          1    5.8756  5.8756  50.306 0.22034  0.001 ***
## Residuals 178   20.7901  0.1168         0.77966           
## Total     179   26.6658                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU126_Glomus          OTU213_Rhizophagus     OTU118_Rhizophagus    
##  [4] OTU106_Sordariomycetes OTU322_Fusarium        OTU32_Fusarium        
##  [7] OTU16_Fusarium         OTU18_Gibberella       OTU19_Sarocladium     
## [10] OTU2_Setophoma         OTU136_Auriculariales  OTU110_Myrmecridium   
## [13] OTU35_Myrothecium      OTU197_Fungi           OTU535_Pezizaceae     
## [16] OTU151_Vermispora     
## 16 Levels: OTU126_Glomus OTU213_Rhizophagus ... OTU151_Vermispora
## [1] OTU5_Acremonium        OTU22_Periconia        OTU105_Aspergillus    
## [4] OTU109_Beauveria       OTU97_Penicillium      OTU221_Spiromastix    
## [7] OTU102_Arthropsis      OTU212_Sordariomycetes
## 8 Levels: OTU5_Acremonium OTU22_Periconia ... OTU212_Sordariomycetes

manhatan.drought("Root", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va         1    1.1178 1.11777  19.503 0.17183  0.001 ***
## Residuals 94    5.3874 0.05731         0.82817           
## Total     95    6.5052                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU229_Glomus          OTU126_Glomus          OTU133_Glomus         
##  [4] OTU213_Rhizophagus     OTU132_Rhizophagus     OTU161_Rhizophagus    
##  [7] OTU118_Rhizophagus     OTU150_Rhizophagus     OTU166_Rhizophagus    
## [10] OTU106_Sordariomycetes OTU182_Ascomycota      OTU123_Hypocreales    
## [13] OTU60_Hypocreales      OTU153_Auriculariales  OTU136_Auriculariales 
## [16] OTU1_Cladosporium      OTU319_Entoloma        OTU110_Myrmecridium   
## [19] OTU56_Agaricomycetes   OTU55_Panaeolus        OTU23_Stachybotrys    
## [22] OTU535_Pezizaceae     
## 22 Levels: OTU229_Glomus OTU126_Glomus ... OTU535_Pezizaceae
## [1] OTU16_Fusarium OTU486_Fungi  
## Levels: OTU16_Fusarium OTU486_Fungi

manhatan.drought("Rhizosphere", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va          1     3.594  3.5941  22.264 0.11117  0.001 ***
## Residuals 178    28.734  0.1614         0.88883           
## Total     179    32.329                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU408_Fungi           OTU106_Sordariomycetes OTU322_Fusarium       
##  [4] OTU41_Fusarium         OTU32_Fusarium         OTU16_Fusarium        
##  [7] OTU6_Fusarium          OTU18_Gibberella       OTU19_Sarocladium     
## [10] OTU136_Auriculariales  OTU83_Cladosporium     OTU35_Myrothecium     
## [13] OTU151_Vermispora     
## 13 Levels: OTU408_Fungi OTU106_Sordariomycetes ... OTU151_Vermispora
## [1] OTU5_Acremonium    OTU222_Aspergillus OTU105_Aspergillus
## [4] OTU109_Beauveria   OTU97_Penicillium  OTU221_Spiromastix
## 6 Levels: OTU5_Acremonium OTU222_Aspergillus ... OTU221_Spiromastix

manhatan.drought("Rhizosphere", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va         1    2.9474 2.94741  31.177 0.24906  0.001 ***
## Residuals 94    8.8866 0.09454         0.75094           
## Total     95   11.8340                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##  [1] OTU106_Sordariomycetes OTU27_Alternaria       OTU4_Alternaria       
##  [4] OTU11_Epicoccum        OTU136_Auriculariales  OTU83_Cladosporium    
##  [7] OTU1_Cladosporium      OTU319_Entoloma        OTU24_Cryptococcus    
## [10] OTU10_Filobasidium     OTU69_Tremellomycetes  OTU90_Rhodotorula     
## [13] OTU26_Sporobolomyces   OTU14_Symmetrospora   
## 14 Levels: OTU106_Sordariomycetes OTU27_Alternaria ... OTU14_Symmetrospora
## [1] OTU5_Acremonium   OTU32_Fusarium    OTU16_Fusarium    OTU18_Gibberella 
## [5] OTU19_Sarocladium OTU2_Setophoma    OTU137_Eurotiales OTU97_Penicillium
## [9] OTU197_Fungi     
## 9 Levels: OTU5_Acremonium OTU32_Fusarium ... OTU197_Fungi

manhatan.drought("Soil", 2, "Post_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va          1     0.715 0.71500  6.2473 0.03391  0.001 ***
## Residuals 178    20.372 0.11445         0.96609           
## Total     179    21.087                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] OTU133_Glomus OTU277_Glomus OTU224_Glomus OTU206_Glomus
## Levels: OTU133_Glomus OTU277_Glomus OTU224_Glomus OTU206_Glomus
## [1] OTU51_Rhizophagus     OTU5_Acremonium       OTU170_Fungi         
## [4] OTU17_Acrophialophora OTU59_Chaetomium     
## 5 Levels: OTU51_Rhizophagus OTU5_Acremonium ... OTU59_Chaetomium

manhatan.drought("Soil", 9, "Pre_flowering_drought","Treatment1" )
## 
## Call:
## adonis(formula = com ~ va) 
## 
## Permutation: free
## Number of permutations: 999
## 
## Terms added sequentially (first to last)
## 
##           Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)    
## va         1    0.4663 0.46633  4.4716 0.04541  0.001 ***
## Residuals 94    9.8031 0.10429         0.95459           
## Total     95   10.2694                 1.00000           
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] OTU14_Symmetrospora
## Levels: OTU14_Symmetrospora
## [1] OTU17_Acrophialophora OTU97_Penicillium    
## Levels: OTU17_Acrophialophora OTU97_Penicillium